#ifndef BOSS_Afterburner_Globals_Functions_Error_H
#define BOSS_Afterburner_Globals_Functions_Error_H

#include "TString.h"

#define TO_STRING(x) #x
#define EXCEPTION(VARIABLE)                 \
  throw BOSS_Afterburner::Error::Exception( \
    Form("%s:%d (%s):\n  %s", __FILE__, __LINE__, __func__, VARIABLE))

namespace BOSS_Afterburner
{
  /// @addtogroup Afterburner_functions
  /// @{
  /// Exception handling.
  /// @author  Remco de Boer 雷穆克 (r.e.deboer@students.uu.nl or remco.de.boer@ihep.ac.cn)
  /// @date    November 20th, 2018
  namespace Error
  {
    class Exception : public std::runtime_error
    {
    public:
      Exception(const TString& msg) : fMessage{msg}, std::runtime_error(msg.Data()) {}
      virtual void PrintWarning() const;

    private:
      const TString fMessage;
    };
  } // namespace Error
  /// @}
} // namespace BOSS_Afterburner

#endif